package com.bawei.a2010douyin.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

/**
 * 评论框弹出：不拦截
 * 评论框关闭：拦截
 */
public class VideoRecyclerView extends RecyclerView {
    private boolean interceptor = false;// true拦截 false不拦截

    public void setInterceptor(boolean interceptor) {
        this.interceptor = interceptor;
    }

    public VideoRecyclerView(@NonNull Context context) {
        super(context);
    }

    public VideoRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public VideoRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        if(!interceptor){
            return false;//不拦截
        }
        return super.onInterceptTouchEvent(e);//默认拦截
    }
}
